package com.heatup.apt.api.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.heatup.apt.api.service.UserAccountConsumeService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.framework.service.impl.SuperServiceImpl;
import com.baomidou.mybatisplus.plugins.Page;
import com.heatup.apt.common.dao.user.UserAccountConsumeMapper;
import com.heatup.apt.model.user.UserAccountConsume;
import com.heatup.apt.model.user.UserAccountRecharge;

/**
 * 用户消费实现类
 * 
 * @author jixiangyun 2016年12月12日 上午10:54:25
 */

@Service
public class UserAccountConsumeServiceImpl extends  SuperServiceImpl<UserAccountConsumeMapper,UserAccountConsume> implements UserAccountConsumeService {

	private static final Logger logger = LoggerFactory.getLogger(UserAccountConsumeServiceImpl.class);
	
	@Autowired
	private UserAccountConsumeMapper userAccountConsumeMapper;

	/**
	 * 查询用户的消费记录和充值记录
	 * type: 1 消费记录
	 * type: 2 充值记录
	 */
	@Override
	public Map<String, Object> queryUserAccountConsumeList(Map<String, Object> map) {
		Map<String, Object> responseMap = new HashMap<String, Object>();
		logger.info("=============================== query user account Consume list start parameter:======================"+map);
		Integer pageIndex = (Integer) map.get("pageIndex");
		Integer pageSize = (Integer) map.get("pageSize");
		Page<UserAccountConsume> accountConsumePage = new Page<>(pageIndex, pageSize);
		Page<UserAccountRecharge> accountRechargePage = new Page<>(pageIndex, pageSize);
		if (pageIndex > 0)
            --pageIndex;
        if (pageSize <=0)
            pageSize = 10;
		// 消费记录
		if("1".equals(map.get("type"))){
			List<UserAccountConsume> list = userAccountConsumeMapper.selectByMap(map);
			responseMap.put("list",list);
		}else{
			
		}
		return responseMap;
	}
	
	/**
	 * 新的分页查询
	 */
	@Override
	public Page<UserAccountConsume> queryUserAccountConsumePage(Page<UserAccountConsume> userAccountConsumePage,
			Map<String, Object> paramsMap) {
		userAccountConsumePage.setRecords(userAccountConsumeMapper.queryUserAccountConsumegPage(userAccountConsumePage, paramsMap));
        return userAccountConsumePage;
		
	}

}
